#ifndef GAME_CONTROLLER_HH
#define GAME_CONTROLLER_HH

#include "IGameController.hh"
#include "GetEnemyPosition.hh"
#include "characters/Player.hh"
#include "map.hh"
#include <memory>
using std::string;

/**
 * @class GameController
 * @brief Manages the overall flow and rules of the game.
 *
 * Implements the IGameController interface, controlling game state transitions,
 * player actions, enemy behaviors, and other game-wide logic.
 */

class GameController : public IGameController {
private:
    Player& player;
    int getLocationType(int x, int y) const;
    //GetEnemyPosition enemy;
    Map gameMap;
    //time_t demonAwakeTime;

    void updatePlayerPosition(char input);
    int playerX = 0;
    int playerY = 1;
    bool gameOver = false;
    bool inSpecimenRoom = false;
    bool hasIDCard = false;
    bool hasDiary = false;
    void handleDemonEncounter();
public:
    std::vector<Item*> items;
    std::vector<bool> collectedItems;

    GameController(Player& p);
    bool checkSimpleEnding() const;
   // bool checkHiddenEnding() const;
    bool isGameOver() const override;
    void initializeGame();
    char processPlayerMove();
    void displayGameState();
    void initializeItems();
    void handleLocationEvents();
    Player& getPlayer();
    Map getMap();
    void gamerun();
};

#endif